import time

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
# from common.logger import logger
# from common.screenshot import take_screenshot

class BasePage:
    def __init__(self, driver):
        self.driver = driver
        self.wait = WebDriverWait(driver, 10)

    def find(self, locator):
        try:
            return self.wait.until(EC.presence_of_element_located(locator))

        except TimeoutException:
            self.driver.refresh()
            time.sleep(15)
            raise

    def click(self, locator):
        print('dianjiwancheng')

        return self.find(locator).click()


    def send_keys(self, locator, text):
        ele = self.find(locator)
        ele.clear()
        ele.send_keys(text)